package com.company;

// 拷贝数组,从某索引到某索引，并赋值到新的数据
public class Test1 {

    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

        // 拷贝数组
        int[] result = copyOfArray(arr, 3, 7);

        for (int i = 0; i < result.length; i++) {
            System.out.print(result[i] + " ");
        }
    }

    public static int[] copyOfArray(int[] arr, int from, int to) {
        int[] result = new int[to - from];
        int index = 0;
        for(int i = from; i < to; i++) {
            result[index++] = arr[i];
        }
        return result;
    }
}
